<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>app用户操作管理</title>
    <%@ include file="/WEB-INF/view/common/includ-css.jsp" %>
</head>
<body class="gray-bg">
<div class="row wrapper border-bottom white-bg">
    <div class="col-sm-12">
        <div class="ibox float-e-margins" style="margin-bottom: 0px;">
            <div class="ibox-title">
                <h5>新增用户</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form class="form-inline">
                    <a href="${path}/app/user/add/index" class="btn btn-white btn-info btn-round">新增人员</a>
                </form>
            </div>
            <div class="ibox-title">
                <h5>清除缓存</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form class="form-inline">
                    <div class="form-group">
                        <label class="font-normal">手机号码：</label>
                        <input type="text" id="phone" name="phone"/>
                    </div>
                    <button type="button" class="btn btn-white btn-info btn-round" style="margin-bottom: 0px;" id="phoneRedis">
                        <i class="ace-icon fa fa-search bigger-120 blue">清除</i>
                    </button>
                </form>
            </div>
            <div class="ibox-title">
                <h5>ip限制</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form class="form-inline">
                    <div class="form-group">
                        <label class="font-normal">ip：</label>
                        <input type="text" id="userIp" name="userIp"/>
                    </div>
                    <button type="button" class="btn btn-white btn-info btn-round" style="margin-bottom: 0px;" id="blackIp">
                        <i class="ace-icon fa fa-search bigger-120 blue">拉黑</i>
                    </button>
                    <button type="button" class="btn btn-white btn-info btn-round" style="margin-bottom: 0px;" id="blackIpUn">
                        <i class="ace-icon fa fa-search bigger-120 blue">解除</i>
                    </button>
                </form>
            </div>
            <div class="ibox-title">
                <h5>群成员拉黑</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form class="form-inline">
                    <div class="form-group">
                        <label class="font-normal">电话：</label>
                        <input type="text" id="groupUserPhone" name="groupUserPhone"/>
                    </div>
                    <div class="form-group">
                        <label class="font-normal">群id：</label>
                        <input type="text" id="groupId" name="groupId"/>
                    </div>
                    <button type="button" class="btn btn-white btn-info btn-round" style="margin-bottom: 0px;" id="groupBlackUser">
                        <i class="ace-icon fa fa-search bigger-120 blue">拉黑</i>
                    </button>
                    <button type="button" class="btn btn-white btn-info btn-round" style="margin-bottom: 0px;" id="groupBlackUserUn">
                        <i class="ace-icon fa fa-search bigger-120 blue">解除</i>
                    </button>
                </form>
            </div>
            <div class="ibox-title">
                <h5>清除用户信息</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form class="form-inline">
                    <div class="form-group">
                        <label class="font-normal">用户id：</label>
                        <input type="text" id="delUserId" name="delUserId"/>
                    </div>
                    <button type="button" class="btn btn-white btn-info btn-round" style="margin-bottom: 0px;" id="delData">
                        <i class="ace-icon fa fa-search bigger-120 blue">确定</i>
                    </button>
                </form>
            </div>
            <div class="ibox-title">
                <h5>刷新用户好友缓存</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form class="form-inline">
                    <div class="form-group">
                        <label class="font-normal">用户id：</label>
                        <input type="text" id="userId" name="userId"/>
                    </div>
                    <button type="button" class="btn btn-white btn-info btn-round" style="margin-bottom: 0px;" id="refreshUserFriends">
                        <i class="ace-icon fa fa-search bigger-120 blue">确定</i>
                    </button>
                </form>
            </div>
            <div class="ibox-title">
                <h5>时间段转账未领取重新添加缓存</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form class="form-inline">
                    <div class="form-group">
                        <label class="font-normal">结束时间：</label>
                        <input type="text" id="endTime" name="endTime"/>
                        <label class="font-normal" style="color:red">(2020-01-01 00:00:00)</label>
                    </div>
                    <button type="button" class="btn btn-white btn-info btn-round" style="margin-bottom: 0px;" id="redAllAdd">
                        <i class="ace-icon fa fa-search bigger-120 blue">确定</i>
                    </button>
                </form>
            </div>
            <div class="ibox-title">
                <h5>时间段红包未领取重新添加缓存</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form class="form-inline">
                    <div class="form-group">
                        <label class="font-normal">结束时间：</label>
                        <input type="text" id="transEndTime" name="transEndTime"/>
                        <label class="font-normal" style="color:red">(2020-01-01 00:00:00)</label>
                    </div>
                    <button type="button" class="btn btn-white btn-info btn-round" style="margin-bottom: 0px;" id="transAllAdd">
                        <i class="ace-icon fa fa-search bigger-120 blue">确定</i>
                    </button>
                </form>
            </div>
        </div>
    </div>
</div>

<%@ include file="/WEB-INF/view/common/includ-js.jsp" %>
<!-- Data Tables -->
<script src="${path}/static/Hui/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="${path}/static/Hui/js/plugins/dataTables/dataTables.bootstrap.js"></script>
<script src="${path}/static/plugins/layui/layui.all.js"></script>
<script>

    $("#phoneRedis").click(function(){
        var phone = $("#phone").val();
        if(phone==''){
            layer.alert("请输入电话号码",{icon:2});
            return;
        }
        redisInfo(phone);
    });
    $("#blackIp").click(function(){
        var userIp = $("#userIp").val();
        if(userIp==''){
            layer.alert("请输入IP地址",{icon:2});
            return;
        }
        blackIp(userIp);
    });
    $("#blackIpUn").click(function(){
        var userIp = $("#userIp").val();
        if(userIp==''){
            layer.alert("请输入IP地址",{icon:2});
            return;
        }
        blackIpUn(userIp);
    });

    $("#groupBlackUser").click(function(){
        var groupUserPhone = $("#groupUserPhone").val();
        if(groupUserPhone==''){
            layer.alert("电话号码不能为空",{icon:2});
            return;
        }
        var groupId = $("#groupId").val();
        if(groupId==''){
            layer.alert("群id不能为空",{icon:2});
            return;
        }
        groupBlackUser(groupUserPhone,groupId);
    });
    $("#groupBlackUserUn").click(function(){
        var groupUserPhone = $("#groupUserPhone").val();
        if(groupUserPhone==''){
            layer.alert("电话号码不能为空",{icon:2});
            return;
        }
        var groupId = $("#groupId").val();
        if(groupId==''){
            layer.alert("群id不能为空",{icon:2});
            return;
        }
        groupBlackUserUn(groupUserPhone,groupId);
    });
    $("#redAllAdd").click(function(){
        var endTime = $("#endTime").val();
        if(endTime==''){
            layer.alert("结束时间不能为空",{icon:2});
            return;
        }
        redAllAdd(endTime);
    });
    $("#transAllAdd").click(function(){
        var transEndTime = $("#transEndTime").val();
        if(endTime==''){
            layer.alert("结束时间不能为空",{icon:2});
            return;
        }
        transAllAdd(transEndTime);
    });
    $("#refreshUserFriends").click(function(){
        var userId = $("#userId").val();
        if(userId==''){
            layer.alert("用户id不能为空",{icon:2});
            return;
        }
        refreshUserFriends(userId);
    });

    function blackIp(userIp){
        layer.confirm("是否拉黑当前ip:"+userIp, function (e) {
            var index = layer.load(2);
            $.ajax({
                type:"post",
                url:"${path}/app/user/user/ip/black",
                dataType:"json",
                data:{userIp:userIp},
                success:function(data){
                    layer.close(index);
                    if(data.code ==0){
                        layer.alert(data.msg,{icon:1}, function(){
                            location.reload();
                        });
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },
                error:function (data) {
                    layer.close(index);
                }
            });
        });
    }
    function blackIpUn(blackIp){
        layer.confirm("是否解除当前ip:"+blackIp, function (e) {
            var index = layer.load(2);
            $.ajax({
                type:"post",
                url:"${path}/app/user/user/ip/black/un",
                dataType:"json",
                data:{userIp:blackIp},
                success:function(data){
                    layer.close(index);
                    if(data.code ==0){
                        layer.alert(data.msg,{icon:1}, function(){
                            location.reload();
                        });
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },
                error:function (data) {
                    layer.close(index);
                }
            });
        });
    }

    function redisInfo(phone){
        if(phone==""){
            layer.alert("请输入电话号码",{icon:2});
        }
        layer.confirm("当前人员是否清除缓存", function (e) {
            var index = layer.load(2);
            $.ajax({
                type:"post",
                url:"${path}/app/user/redisInfo",
                dataType:"json",
                data:{phone:phone},
                success:function(data){
                    layer.close(index);
                    if(data.code ==0){
                        layer.alert(data.msg,{icon:1}, function(){
                            location.reload();
                        });
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },
                error:function (data) {
                    layer.close(index);
                }
            });
        });
    }
    function groupBlackUser(groupUserPhone,groupId){
        layer.confirm("是否拉黑当前用户:"+groupUserPhone, function (e) {
            var index = layer.load(2);
            $.ajax({
                type:"post",
                url:"${path}/app/user/group/black/user",
                dataType:"json",
                data:{groupUserPhone:groupUserPhone,groupId:groupId},
                success:function(data){
                    layer.close(index);
                    if(data.code ==0){
                        layer.alert(data.msg,{icon:1}, function(){
                            location.reload();
                        });
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },
                error:function (data) {
                    layer.close(index);
                }
            });
        });
    }
    function groupBlackUserUn(groupUserPhone,groupId){
        layer.confirm("是否解除当前用户:"+groupUserPhone, function (e) {
            var index = layer.load(2);
            $.ajax({
                type:"post",
                url:"${path}/app/user/group/black/user/un",
                dataType:"json",
                data:{groupUserPhone:groupUserPhone,groupId:groupId},
                success:function(data){
                    layer.close(index);
                    if(data.code ==0){
                        layer.alert(data.msg,{icon:1}, function(){
                            location.reload();
                        });
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },
                error:function (data) {
                    layer.close(index);
                }
            });
        });
    }

    $("#delData").click(function(){
        var delUserId = $("#delUserId").val();
        if(delUserId==''){
            layer.alert("用户id不能为空",{icon:2});
            return;
        }
        delData(delUserId);
    });
    function delData(userId){
        layer.confirm("是否删除当前用户信息:"+userId, function (e) {
            var index = layer.load(2);
            $.ajax({
                type:"post",
                url:"${path}/app/user/del/data",
                dataType:"json",
                data:{userId:userId},
                success:function(data){
                    layer.close(index);
                    if(data.code ==0){
                        layer.alert(data.msg,{icon:1}, function(){
                            location.reload();
                        });
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },
                error:function (data) {
                    layer.close(index);
                }
            });
        });
    }

    function redAllAdd(endTime){
        layer.confirm("重置缓存", function (e) {
            var index = layer.load(2);
            $.ajax({
                type:"post",
                url:"${path}/app/user/red/all/add/redis",
                dataType:"json",
                data:{endTime:endTime},
                success:function(data){
                    layer.close(index);
                    if(data.code ==0){
                        layer.alert(data.msg,{icon:1}, function(){
                            location.reload();
                        });
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },
                error:function (data) {
                    layer.close(index);
                }
            });
        });
    }

    function transAllAdd(endTime){
        layer.confirm("重置缓存", function (e) {
            var index = layer.load(2);
            $.ajax({
                type:"post",
                url:"${path}/app/user/trans/all/add/redis",
                dataType:"json",
                data:{endTime:endTime},
                success:function(data){
                    layer.close(index);
                    if(data.code ==0){
                        layer.alert(data.msg,{icon:1}, function(){
                            location.reload();
                        });
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },
                error:function (data) {
                    layer.close(index);
                }
            });
        });
    }
    function refreshUserFriends(userId){
        layer.confirm("重置缓存", function (e) {
            var index = layer.load(2);
            $.ajax({
                type:"post",
                url:"${path}/app/user/refresh/user/friends",
                dataType:"json",
                data:{userId:userId},
                success:function(data){
                    layer.close(index);
                    if(data.code ==0){
                        layer.alert(data.msg,{icon:1}, function(){
                            location.reload();
                        });
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },
                error:function (data) {
                    layer.close(index);
                }
            });
        });
    }

</script>
</body>
</html>
